/*
**
**  P78
**
*/

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

#define MAXOP 100
#define INFINITY 1e9

typedef enum { num, opr, end } Type;

typedef struct SNode* PtrToSNode;

struct SNode {
    double Data;
    PtrToSNode Next;
};

typedef PtrToSNode Stack;

Stack CreateStack ();

bool IsEmpty ( Stack S );

bool Push ( Stack S, double X );

double Pop ( Stack S );

Type GetOp ( char* Expr, int* start, char* str );

double PostfitExp ( char* Expr );

int main() {
    char Expr[MAXOP];
    double f;

    gets(Expr);
    f = PostfitExp(Expr);
    if ( f < INFINITY ) printf("%.4f\n",f);
    else printf("Err Expression\n");
    
    return 0;

}

Stack CreateStack () {
    Stack S;
    S = (Stack)malloc(sizeof(struct SNode));
    S->Data = 0;
    S->Next = NULL;
    return S;
}

bool IsEmpty ( Stack S ) {
    return ( S->Next == NULL );
}

bool Push ( Stack S, double X ) {
    Stack tmp;
    tmp = (Stack)malloc(sizeof(struct SNode));
    tmp->Data = X;
    tmp->Next = S->Next;
    S->Next = tmp;
    return true;
}

double Pop ( Stack S ) {
    if ( IsEmpty(S) == true ) {
        printf("Empty! Can't pop!\n");
        exit(-8);
    }
    double X;
    Stack tmp = S->Next;
    X = tmp->Data;
    S->Next = tmp->Next;
    free(tmp);
    return X;
}

Type GetOp ( char* Expr, int *start, char* str ) {
    int i = 0;

    while ( ( str[0] = Expr[ ( *start )++ ]) == ' ' );

    while ( str[i] != ' ' && str[i] != '\0' ) str[++i] = Expr[ (*start)++ ];

    if ( str[i] == '\0' ) ( *start )--;
    str[i] = '\0';

    if ( i == 0 ) return end;
    else if ( ( str[0] >= '0' && str[0] <= '9' ) || ( str[1] >= '0' && str[1] <= '9' ) ) return num;
    else return opr;    
}

double PostfitExp ( char* Expr ) {
    Stack S;
    Type T;
    double Op1, Op2;
    char str[MAXOP];
    int start = 0;

    S = CreateStack ( MAXOP );

    Op1 = Op2 = 0;
    while ( ( T = GetOp ( Expr, &start, str )) != end ) {
        if ( T == num ) Push(S, atof(str));
        else {
            if ( !IsEmpty(S) ) Op2 = Pop(S);
            else Op2 = INFINITY;
            if ( !IsEmpty(S) ) Op1 = Pop(S);
            else Op2 = INFINITY;
            switch (str[0]) {
            case '+': Push(S, Op1+Op2); break;
            case '*': Push(S, Op1*Op2); break;
            case '-': Push(S, Op1-Op2); break;
            case '/':
                if ( Op2 > 1.0E-10 || Op2 < -1.0E-10 ) Push(S, Op1/Op2);
                else {
                    printf("Err while dividing\n");
                    Op2 = INFINITY;
                }
                break;
            default: 
                printf("Err opr\n");
                Op2 = INFINITY;
                break;
            }
            if ( Op2 >= INFINITY ) break;
        }
    }
    if ( Op2 < INFINITY )
        if ( !IsEmpty(S) ) Op2 = Pop(S);
        else Op2 = INFINITY;
    free(S);
    return Op2;
}